import  fcgi.Application;
import  fcgi.Connection;
import  fcgi.Request;

import tango.io.stream.Format;
import tango.text.convert.Layout;

class MyApp : FastCGIApplication
{
	
    private FormatOutput!(char) stdout;
    private FormatOutput!(char) stderr;

    this (int id, FastCGIRequest request)
    {
        auto layout = new Layout!(char) ();
        
        stdout = new FormatOutput!(char) (layout, request.stdout);
        stderr = new FormatOutput!(char) (layout, request.stderr);
    }

    int run()
    {
        stdout ("Content-type: text/html\r\n\r\n");
        stdout ("Hello world!\n") ();

        return 0;
    }
}

int main(char[][] args)
{
//    FastCGIConnection connection = new FastCGIConnection ();
//    return FastCGIApplication.loop!(MyApp) (connection, true, 10);

    return FastCGIApplication.loop!(MyApp) (null, true, 10);
}
